<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <style type="text/css">
		#preview{border:1px solid #cccccc; background:#CCC;color:#fff; padding:5px; display:none; position:absolute;}
    td img{width:20px;height:20px;}
	  </style>
   </head>
   <script>
    //修改微帮状态
    function toggleisShow(t,v){
		Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
		$.post("{:U('Admin/Help/editisShow')}",{id:v,isShow:t},function(data,textisShow){
			var json = WST.toJson(data);
			if(json.status=='1'){
				Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
				    location.reload();
			}});
			}else{
				Plugins.closeWindow();
				Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
			}
     	});
    }
    //删除单个微帮
    function delHelp(id){
    	var id = id;
    	Plugins.confirm({title:'信息提示',content:'您确定要删除该微帮吗?',okText:'确定',cancelText:'取消',okFun:function(){
			Plugins.closeWindow();
			Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
			$.post("{:U('Admin/Help/delHelp')}",{id:id},function(data,textisShow){
				var json = WST.toJson(data);
				if(json.status=='1'){
					Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
					    location.reload();
				}});
				}else{
					Plugins.closeWindow();
					Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				}
	     	});
		}});
    }
    //批量删除微帮
    function BatchDelete(){
      var ids = [];
      $('.chk').each(function(){
          if($(this).prop('checked'))ids.push($(this).val());
      })
        Plugins.confirm({title:'信息提示',content:'您确定要删除所选微帮吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
            $.post("{:U('Admin/Help/delSelectHelp')}",{id:ids.join(',')},function(data,textisShow){
                var json = WST.toJson(data);
                if(json.status=='0'){
                    Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
                        location.reload();
                    }});
                }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
                }
            });
        }});
    }
    //批量隐藏微帮
    function hideSelectHelp(){
      var ids = [];
      $('.chk').each(function(){
          if($(this).prop('checked'))ids.push($(this).val());
      })
        Plugins.confirm({title:'信息提示',content:'您确定要隐藏所选微帮吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
            $.post("{:U('Admin/Help/hideSelectHelp')}",{id:ids.join(',')},function(data,textisShow){
                var json = WST.toJson(data);console.log(json);
                if(json.status=='0'){
                    Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
                        location.reload();
                    }});
                }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
                }
            });
        }});
    }
    //批量显示微帮
    function showSelectHelp(){
      var ids = [];
      $('.chk').each(function(){
          if($(this).prop('checked'))ids.push($(this).val());
      })
        Plugins.confirm({title:'信息提示',content:'您确定要显示所选微帮吗?',okText:'确定',cancelText:'取消',okFun:function(){
            Plugins.closeWindow();
            Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
            $.post("{:U('Admin/Help/showSelectHelp')}",{id:ids.join(',')},function(data,textisShow){
                var json = WST.toJson(data);
                if(json.status=='0'){
                    Plugins.setWaitTipsMsg({content:'操作成功',timeout:1000,callback:function(){
                        location.reload();
                    }});
                }else{
                    Plugins.closeWindow();
          Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
                }
            });
        }});
    }
   $.fn.imagePreview = function(options){
		var defaults = {}; 
		var opts = $.extend(defaults, options);
		var t = this;
		xOffset = 5;
		yOffset = 20;
		if(!$('#preview')[0])$("body").append("<div id='preview'><img width='200' src=''/></div>");
		$(this).hover(function(e){
			   $('#preview img').attr('src',"__ROOT__/"+$(this).attr('img'));      
			   $("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").show();      
		  },
		  function(){
			$("#preview").hide();
		}); 
		$(this).mousemove(function(e){
			   $("#preview").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px");
		});
	}
  $(document).ready(function(){
	    $('.imgPreview').imagePreview();
	    //全选
        $("#selected").click(function(){
            $('input[num="list"]').prop('checked',true);
            $('#cancel').attr('checked',false);
        });
        //取消全选
        $("#cancel").click(function(){
            $('input[num="list"]').prop('checked',false);
            $('#selected').attr('checked',false);
        });
  });
   </script>
   <body class='wst-page'>
    <form method='post' action='{:U("Admin/Help/helpList")}'>
   		<div class='wst-tbar'> 
          发布人：<input type='text' id='userName' name='userName' value='{$userName}'/>            
	        标题：<input type='text' id='title' name='title' value='{$title}'/>          
	        内容：<input type='text' id='content' name='content' value='{$content}'/>  
	        状态：<select name="isShow">
					 <option  value="-1" <if condition="$isShow eq -1">selected="selected"</if>>请选择</option>
					 <option  value="1" <if condition="$isShow eq 1">selected="selected"</if>>显示</option>
					 <option  value="0" <if condition="$isShow  eq 0">selected="selected"</if>>隐藏</option>
					</select>
          类型：<select name="cid">
           <option  value="-1" <if condition="$cid eq -1">selected="selected"</if>>请选择</option>
           <volist name="Page['helpCate']" id="vo" key="i">
              <option  value="{$vo['id']}" <if condition="$cid eq $vo['id']">selected="selected"</if>>{$vo['cateName']}</option>
           </volist>
          </select>  
	  		<button type="submit" class="btn btn-primary glyphicon glyphicon-search">查询</button> 
       	</div>
    </form>
       <div class='wst-body'>
        <table class="table table-hover table-striped table-bordered wst-list">
           <thead>
             <tr>
               <th width='50'><input type='checkbox' name='chk' onclick='javascript:WST.checkChks(this,".chk")'/>序号</th>
               <th width='80'>微帮类型</th>
               <th width='120'>标题</th>
               <th width='200'>内容</th>
               <th width='80'>发布人</th>
               <th width='120'>发布时间</th>
               <th width='40'>状态</th>
               <th width='80'>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name="Page['root']" id="vo" key='i'>
             <tr>
               <td><input type='checkbox' class='chk' name='chk_{$vo['id']}' value='{$vo['id']}'/>{$i}</td>
               <td>{$vo['cateName']}</td>
               <td>{$vo['title']}</td>
               <td>{$vo['content']}</td>
               <td>
               		<if condition="$vo['userName'] neq ''">
               			{$vo['userName']}
               			<else />
               			{$vo['userName']}
               		</if>
               </td>
               <td>{$vo['createTime']}</td>
               <td>
                    <div class="dropdown">
                    <if condition="$vo['isShow']==0 ">
                      <button class="btn btn-danger dropdown-toggle wst-btn-dropdown"  type="button" data-toggle="dropdown">隐藏<span class="caret"></span>
                    </button>
                    <else/>
                      <button class="btn btn-success dropdown-toggle wst-btn-dropdown" type="button" data-toggle="dropdown">显示<span class="caret"></span>
                    </button>
                    </if>
                      <ul class="dropdown-menu" role="menu">
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:toggleisShow(1,{$vo['id']})">显示</a></li>
                        <li role="presentation"><a role="menuitem" tabindex="-1" href="javascript:toggleisShow(0,{$vo['id']})">隐藏</a></li>
                     </ul>
                    </div>
               </td>
               <td>
               <a class="btn btn-primary glyphicon" href='{:U("Admin/Help/toDetail",array("id"=>$vo["id"]))}'>查看</a> 
               <php>if(in_array('wblb_03',$WST_STAFF['grant'])){</php>
               <button type="button" class="btn btn-danger" onclick="javascript:delHelp({$vo['id']})">删除</button>
               <php>}</php>
               </td>
             </tr>
             </volist>
		       <tr>
		            <td colspan='9' style="background:none;;">
		                <input type='checkbox' name='chk' onclick='javascript:WST.checkChks(this,".chk")'/>全选/取消
		                <input type="button" onclick="javascript:BatchDelete()" value="批量删除"/>
	                    <input type="button" onclick="javascript:hideSelectHelp()" value="批量隐藏"/>
	                    <input type="button" onclick="javascript:showSelectHelp()" value="批量显示"/>
		            </td>
		          </tr>
             <tr>
                <td colspan='9' align='center'>{$Page['pager']}</td>
             </tr>
           </tbody>
        </table>
       </div>
   </body>
</html>